<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../../inc.jsp"></jsp:include>
	<script type="text/javascript">
	
	
		function initQuery()
        {
       
		        var dg = $("#sdatatab");
				var pager = dg.datagrid('getPager');
                pager.pagination({
			        onSelectPage: function (pageNum, pageSize) 
			        {
			            loadPageData(pageNum, pageSize,dg);
			        }
		        });
        }
        ///
        function loadPageData(pageNum, pageSize,dg)
        {
        alert(pageNum + "kk" + pageSize);
             var param = "";
             $.ajax({
                     url:'toDoInfoAction!find.action',
                     ///platform/system/datagrid_data2.json
                     async :false,
                     success:function(result)
                   	 {
                   	    data = eval('(' + result + ')')
                   	    var pager = dg.datagrid('getPager');

		                //from local cache
		                var start = (pageNum - 1) * parseInt(pageSize);
					    var end = start + parseInt(pageSize);
					    var rows = data.rows.slice(start, end);
					    
					    for(var i=0;i<rows.length;i++)
					    {
					       rows[i].op = "<a href=\"javascript:doView("+i+");\">查看</a>";
					    }					    
					    dg.datagrid('loadData', rows);					    
					   
					    pager.pagination('refresh', {
		                    total:data.total,
			                pageNumber: pageNum,
			                pageSize: pageSize
			             });
                   	 }
             });
        }
        function doQuery()
        {
        $("#sdatatab").datagrid({
            columns: [[
                
                { field: 'c_name', title: '日期字段', width: 100, align: 'center' },
                { field: 'c_title', title: '日期字段', width: 100, align: 'center' },
                { field: 'op', title: '操作', width: 100, align: 'center' }
            ]],
            height: 150, 
            pagination: true, 
            pagePosition: "bottom", 
            sortname: "id", 
            sortorder: "asc", /*desc*/
            multiSort: true, 
            remoteSort: false, 
            pageSize: 5, 
            pageList: [5, 15, 20,30,40],
            autoRowHeight: false, 
            fitColumns: true, 
            rownumbers: true, /*是否显示行号*/
            singleSelect: true, 
            striped: true /*是否启用隔行渐变*/
        });       
            initQuery();
            
            var dg = $("#sdatatab");
            
            var pager = dg.datagrid('getPager');
            pager.pagination('select',1);
        } 
	function load()
{
alert("<%=request.getContextPath()%>");
doQuery();
}	
			function _search() {
	    alert("searchbun");
		//datagrid.datagrid('load', dagong.serializeObject($('#searchForm')));
	}
		</script>
  </head>
  <body onload="load()">  		
		
  		<div data-options="region:'center',border:false" style="overflow:hidden">
						<table id="sdatatab" ></table>
					</div>
					
    
  </body>
</html>
